<?php
namespace app\web\model;

use think\Model;

/**
 * @手册分类
 */
class ManualGroupModel extends Model
{
    // 设置数据表（不含前缀）
    protected $name = 'manual_group';
    public function __construct($data = [])
    {
        parent::__construct($data);
    }
    
    public function Manual()
    {
        return $this->hasMany('ManualModel','group','id');
    }
    
    /**
     * @获取数据
     * 
     */
    public function selectListData($where=[['status','eq',1]],$manualWhere=[]){
            
           $where[] = ['status','eq',1];
           $manualWhere[]=['status','eq',1];
           $return = $this::with(['Manual'=>function($query)use ($manualWhere){
                    $query->where($manualWhere)->field('id,title,group')->order('sort desc,id desc');
                }])->where($where)->select();
            return $return;
    }
    
    /*
     * @获取一级分类
     */
    public function selectParentList(){
            $data = $this::where([['pid','eq',0],['status','eq',1]])->order('sort desc,id desc')->select();
            return $data;
    }
}
